
<!DOCTYPE html>
<html>
  <head>
    
<meta charset="utf-8" >

<title>将 Linux 上的 VSCode 改为 Consolas 字体 | Blog</title>
<meta name="description" content="个人生活，学习记录">

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link rel="shortcut icon" href="https://qiaoxu123.github.io/favicon.ico?v=1589072669553">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css">
<link rel="stylesheet" href="https://qiaoxu123.github.io/styles/main.css">



<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js"></script>



  </head>
  <body>
    <div id="app" class="main">
      <div class="site-header-container">
  <div class="site-header">
    <div class="left">
      <a href="https://qiaoxu123.github.io">
        <img class="avatar" src="https://qiaoxu123.github.io/images/avatar.png?v=1589072669553" alt="" width="32px" height="32px">
      </a>
      <a href="https://qiaoxu123.github.io">
        <h1 class="site-title">Blog</h1>
      </a>
    </div>
    <div class="right">
      <transition name="fade">
        <i class="icon" :class="{ 'icon-close-outline': menuVisible, 'icon-menu-outline': !menuVisible }" @click="menuVisible = !menuVisible"></i>
      </transition>
    </div>
  </div>
</div>

<transition name="fade">
  <div class="menu-container" style="display: none;" v-show="menuVisible">
    <div class="menu-list">
      
        
          <a href="https://qiaoxu123.github.io" class="menu purple-link">
            首页
          </a>
        
      
        
          <a href="https://qiaoxu123.github.io/archives" class="menu purple-link">
            归档
          </a>
        
      
        
          <a href="https://qiaoxu123.github.io/tags" class="menu purple-link">
            标签
          </a>
        
      
    </div>
  </div>
</transition>


      <div class="content-container">
        <div class="post-detail">
          
          <h2 class="post-title">将 Linux 上的 VSCode 改为 Consolas 字体</h2>
          <div class="post-info post-detail-info">
            <span><i class="icon-calendar-outline"></i> 2020-04-26</span>
            
              <span>
                <i class="icon-pricetags-outline"></i>
                
                  <a href="https://qiaoxu123.github.io/tag/Uo0xtLaU1/">
                    效率提升
                    
                  </a>
                
              </span>
            
          </div>
          <div class="post-content">
            <p>转载自<a href="https://blog.gloriousdays.pw/2018/08/29/change-font-within-vsc-to-consolas-on-linux/">博客</a></p>
<!-- more -->
<p>Linux 上的 VSCode 写起代码来总让人觉得莫名烦躁，而 Windows 上面的 VSC 就赏心悦目很多，想了很久之后终于发现是默认字体的问题。Windows 上面的 VSCode 默认是 Consolas 字体，在 Ubuntu 上面大概是 Droid Sans 家族的某种版本，实在是不好看，所以换掉。</p>
<p>首先要在 Ubuntu 上安装 Consolas：</p>
<pre><code class="language-shell">wget https://down.gloriousdays.pw/Fonts/Consolas.zip
unzip Consolas.zip
sudo mkdir -p /usr/share/fonts/consolas
sudo cp consola*.ttf /usr/share/fonts/consolas/
sudo chmod 644 /usr/share/fonts/consolas/consola*.ttf
cd /usr/share/fonts/consolas
sudo mkfontscale &amp;&amp; sudo mkfontdir &amp;&amp; sudo fc-cache -fv
</code></pre>
<p>这样就装好了。用 <code>fc-list</code> 可以看所有安装的字体。</p>
<p>之后在 VSC 的 <code>preference</code> 中修改对应的项：</p>
<pre><code class="language-shell">&quot;editor.fontFamily&quot;: &quot;'Consolas', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'&quot;
</code></pre>
<p>这样就可以了</p>
<hr>
<p>2018-11-30 Update：</p>
<p>如果没有 root 权限，由于 <code>~/.fonts</code> 实际上就是用户个人的字体文件夹，因此我们在 <code>$HOME</code>文件夹下也可以做到同样的事情：</p>
<pre><code class="language-shell">wget https://down.gloriousdays.pw/Fonts/Consolas.zip
unzip Consolas.zip
mkdir ~/.fonts
cp consola*.ttf ~/.fonts
cd ~/.fonts
mkfontscale
mkfontdir
fc-cache -fv ~/.fonts
</code></pre>
<p>之后用 <code>fc-list</code> 可以看到新安装的字体，在 VSCode 中也可以进行调整。</p>

          </div>
        </div>

        
          <div class="next-post">
            <a class="purple-link" href="https://qiaoxu123.github.io/post/ubuntu-ooqp-useguide/">
              <h3 class="post-title">
                下一篇：Ubuntu环境下OOQP优化库的基本使用
              </h3>
            </a>
          </div>
          
      </div>

      

      <div class="site-footer">
  <div class="slogan">个人生活，学习记录</div>
  <div class="social-container">
    
      
    
      
    
      
    
      
    
      
    
  </div>
  Powered by <a href="https://github.com/getgridea/gridea" target="_blank">Gridea</a> | <a class="rss" href="https://qiaoxu123.github.io/atom.xml" target="_blank">RSS</a>
</div>


    </div>
    <script type="application/javascript">

hljs.initHighlightingOnLoad()

var app = new Vue({
  el: '#app',
  data: {
    menuVisible: false,
  },
})

</script>




  </body>
</html>
